package com.example.helloffmpeg

import android.os.Bundle
import android.view.SurfaceView
import androidx.appcompat.app.AppCompatActivity
import com.example.helloffmpeg.system.RtspPlayer
class RtspActivity:AppCompatActivity() {

    private lateinit var surfaceView: SurfaceView
    private lateinit var rtspPlayer: RtspPlayer
//    private val RTSP_URL = "rtsp://rtspstream:65db29ede63937b9bf3f85afc4f75e34@zephyr.rtsp.stream/movie"
    private val RTSP_URL = "rtsp://192.168.42.1:8554/video"
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_rtsp)
        surfaceView = findViewById(R.id.surfaceView)
        rtspPlayer = RtspPlayer()
        startPlay()
    }


    private fun startPlay(){
        Thread{
            if (rtspPlayer.openStream(RTSP_URL)) {
                rtspPlayer.decodeAndPlay(surfaceView.holder.surface)
            }
        }.start()
    }

    override fun onDestroy() {
        super.onDestroy()
        rtspPlayer.release()
    }
}